Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

364
Views
Is "pause" event called on any kind of audio stop?

MDN says:

The pause event is sent when a request to pause an activity is handled and the activity has entered its paused state, most commonly after the media has been paused through a call to the element's pause() method.

But what if the audio stops because it stalled, or on an ended event.

Would it still trigger the pause event? Or should I also perform actions on stalled and ended?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The Audio Pause Event

The answer is that the pause event is only emitted after the pause() method is called or BEFORE an ended or seeking event. The seeking event happens when the track position is changed, which causes the player to toggle between pause and play.

The pause event is NOT emitted following a stalled or waiting event because the audio is still in a play state. Also, when the audio src is changed it stops the player, but no pause event is emitted.

The w3.org event specifications don't provide much detail and implementation may vary by browser.

Run the code snippet to monitor audio events on your browser.

"audioprocess,canplay,canplaythrough,complete,durationchange,emptied,ended,loadeddata,loadedmetadata,pause,play,playing,ratechange,seeked,seeking,stalled,suspend,timeupdate,volumechange,waiting".split(",").forEach(name => {
  player.addEventListener(name, (e) => monitor.innerHTML= e.timeStamp.toFixed(2) + ": " + e.type + "\n" + monitor.innerHTML);
});
<small>Click the audio controls to monitor events:</small><br/>
<audio id="player" controls preload="false" src="http://commondatastorage.googleapis.com/codeskulptor-assets/Epoq-Lepidoptera.ogg" type="audio/ogg">
</audio>

<textarea id="monitor" rows=6 style="width:100%"></textarea>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!